/*
 * This file is part of FinVis.
 *
 * FinVis is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FinVis is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with FinVis.  If not, see <http://www.gnu.org/licenses/>
 *
 * @author Stephen Rudolph
 */
#ifndef FIN_INVESTMENT_WIDGET_H
#define FIN_INVESTMENT_WIDGET_H

#include <QDockWidget>
#include "FinInvestment.h"
#include "FinView.h"

class QCheckBox;
class QComboBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QSpinBox;

/**
 * This dock widget allows the user to modify the selected investment, if
 * one exists.
 */
class FinInvestmentWidget : public QDockWidget {
    Q_OBJECT

public:
    FinInvestmentWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
    void reset();

    void enableButtons();
    void disableButtons();
    
    QSize minimumSizeHint() const;
    QSize sizeHint() const;
    
signals:
    void investmentChanged(FinInvestment investment);
private slots:
    void modifyInvestment();
    void principalChanged(int i);
    void startYearChanged(int i);
    void investmentPeriodChanged(const QString &text);
    void investmentTypeChanged(const QString &text);
    void selectedInvestmentChanged();
    void maxInvestmentRequested();
private:
    QSize m_widgetSize;
    bool m_loading;

    QComboBox *m_investmentPeriod;
    QLabel *m_investmentPeriodLabel;
    QComboBox *m_investmentType;
    QLabel *m_investmentTypeLabel;
    QSpinBox *m_principalSpin;
    QLabel *m_principalLabel;
    QPushButton *m_maxPrincipalButton;
    QSpinBox *m_startYearSpin;
    QLabel *m_startYearLabel;
    QSpinBox *m_endYearSpin;
    QLabel *m_endYearLabel;
    QLineEdit *m_interestEdit;
    QLabel *m_interestLabel;
    QLineEdit *m_riskEdit;
    QLabel *m_riskLabel;
    FinInvestment *m_investment;

    int *m_liquidAssets, m_currentPeriodIndex, m_currentPrincipal;
    int m_currentStartYear, m_currentTypeIndex;
};

#endif
